/**
 * 
 */
package com.gosophia.conferenceManagement.jbpm;

import org.apache.log4j.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.node.DecisionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.conferenceManagement.ConferenceConfiguration;


/**
 * 功能：根据会议类型（大型会议、小型会议、中型会议）判断流程中经过的环节
 * 此方法会驱动流程越过某些环节，详细的会议类型解释参看界面原型   
 * @author zhangdongsheng
 * @since  2011-3-23
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Service
@Transactional
public class ConferenceTypeDecisionHandler implements DecisionHandler {
  
    private final Logger logger = Logger.getLogger(this.getClass());
    @Autowired
    private ConferenceConfiguration conferenceConfiguration;
    @Override
    public String decide(ExecutionContext executionContext) throws Exception {
        
        String nodeName =  executionContext.getNode().getName();//根据所在的节点名称分别进行判断
        
        String conferentType = executionContext.getVariable(conferenceConfiguration.CONFERENCE_TYPE)!=null
        ?(String)executionContext.getVariable(conferenceConfiguration.CONFERENCE_TYPE)
                :"";//会议类型：大 中 小型会议  
        String distTransition="是";
        
        if("是否有方案".equalsIgnoreCase(nodeName) 
                && conferenceConfiguration.MIDDLE_TYPE_CONFERENCE.equals(conferentType)) //在‘是否有方案’节点进行的判断
            distTransition=  "否";  
        
        if ("是否有会务".equalsIgnoreCase(nodeName )&& conferenceConfiguration.SMALL_TYPE_CONFERENCE.equals(conferentType)) 
            distTransition=  "否";   
               
        logger.debug("【"+ nodeName + "节点】 取得会议类型 confernceType：["+conferentType+"] 判定的 目标 transition：[" + distTransition+"]");
        return distTransition;
 
    }
   
    }
